package com.ycfmedical.bed.local.dao;

import android.content.Context;

import com.ycfmedical.bed.greendao.gen.DaoSession;
import com.ycfmedical.bed.local.entity.StaffInfo;
import com.ycfmedical.bed.utils.AssetsHelper;
import com.ycfmedical.bed.utils.GsonHelper;

import java.util.List;

/**
 * Created by Administrator on 2017-03-27.
 */

public class StaffDAO {
    // 所有栏目
    private static List<StaffInfo> sAllStaffList;

    private StaffDAO() {
    }
    /**
     * 更新医院职工信息本地数据
     * @param context
     * @param daoSession
     */
    public static void updateLocalData(Context context, DaoSession daoSession) {
        sAllStaffList = GsonHelper.convertEntities(AssetsHelper.readData(context, "StaffTab"), StaffInfo.class);
        com.ycfmedical.bed.greendao.gen.StaffInfoDao beanDao = daoSession.getStaffInfoDao();
        if (beanDao.count() == 0) {
            beanDao.insertInTx(sAllStaffList);
        }
    }

    /**
     * 获取所有用户
     * @return
     */
    public static List<StaffInfo> getAllStaffInfoList() {
        return sAllStaffList;
    }
}
